<?php
/**
 * Created by PhpStorm.
 * User: Keter
 * Date: 2016/8/12
 * Time: 9:51
 */
class RefreshToken extends RegisterBase
{
    public function logic()
    {
        $userInfo = $this->checkUser(true, ['token']);
        $this->refreshTokenExpire($userInfo);
        $this->returnData('suc_action', null);
    }

    public function refreshTokenExpire($userInfo)
    {
        $key = 'userKey' . $userInfo['uid'];
        $redis = $this->redis('token');

        $expireTime = 30;
        if (GlobalConfig::$redis_expire['game_user_token']) {
            $expireTime = GlobalConfig::$redis_expire['game_user_token'];
        }

        if ($redis->get($key)) {
            $redis->expire($key, $expireTime);
        } else {
            $this->returnError('fault_token', $userInfo);
        }
    }
}